package com.gopay.bis.pab.expay.operation;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import com.gopay.common.Result;
import com.gopay.common.constants.bank.BankConstants;
import com.gopay.common.domain.bank.pab.expay.PabExPayMessage;
import com.gopay.common.domain.bank.pab.expay.SignatureMessage;
import com.gopay.common.domain.bank.pab.expay.res.PabExPayFastpayCPRes;
import com.gopay.common.domain.bank.pab.expay.res.PabExPayFastpayFPARes;
import com.gopay.common.domain.bank.pab.expay.res.PabExPayFastpayFSPRes;
import com.gopay.common.domain.bank.pab.expay.res.PabExPayFastpaySOQRes;
import com.gopay.common.domain.bank.pab.expay.res.PabExPayFastpaySOQResFather;
import com.gopay.common.domain.bank.pab.expay.res.PabExPayFastpaySOQResH;
import com.gopay.common.domain.bank.pab.expay.res.err.MessageErrorRes;
import com.gopay.common.domain.bank.pab.expay.res.err.PabExPayMessageErrorRes;
import com.gopay.common.domain.bank.pab.expay.res.err.PabFastpayErrorRes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignFastpayCPRes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignFastpayFPARes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignFastpayFSPRes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignFastpaySOQRes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignMessageCPRes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignMessageFPARes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignMessageFSPRes;
import com.gopay.common.domain.bank.pab.expay.res.msg.SignMessageSOQRes;
import com.gopay.common.exception.GopayException;
import com.thoughtworks.xstream.XStream;

/**
 * 
 * @ClassName: PabExPayParseData 
 * @Description: TODO(这里用一句话描述这个类的作用) 
 * @author ShenJun 
 * @date 2016年11月29日 下午4:24:19
 */
public class PabExPayParseData {

    protected Log log = LogFactory.getLog(this.getClass());
    
    private DocumentBuilder builder;
    // 生成XPath对象
    private XPath xpath;
    
    private String messageNode = "/Fastpay/Message";
    
    public PabExPayParseData(){
    	try {
			builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			xpath = XPathFactory.newInstance().newXPath();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
    }
    
	public Object parseFpaRes(Object messageData) {
		SignFastpayFPARes fastpay = new SignFastpayFPARes();
		String retString = null;
		if (messageData instanceof byte[]) {
			retString = new String((byte[]) messageData);
		} else if (messageData instanceof String) {
			retString = (String) messageData;
		}

		
		if(retString.indexOf("errorCode")==-1){
			// 解析文件，生成document对象
			try {
				/*InputStream inputStream = new ByteArrayInputStream(retString.getBytes());
				Document document = builder.parse(inputStream);

				// 获取节点值
				//机构标识
				String instId = getStringFromDom("FPARes", "instId", document);
				//交易时间
				String date = getStringFromDom("FPARes", "date", document);
				//银行卡代号
				String signNo = getStringFromDom("FPARes", "signNo", document);
				//消息扩展
				String extension = getStringFromDom("FPARes", "Extension", document);
				//账户分类
				String acntType = getStringFromDom("FPARes", "AcntType", document);
				//银行卡Token号
				String tokenNo = getStringFromDom("FPARes", "TokenNo", document);
				//银行流水号
				String bankSerialNo = getStringFromDom("FPARes", "bankSerialNo", document);*/
				
				SignMessageFPARes signMessageFPARes = new SignMessageFPARes();
				PabExPayFastpayFPARes fastpayFPARes = (PabExPayFastpayFPARes)DomParseXmlUtil.fromXml
						(retString, PabExPayFastpayFPARes.class, "Fastpay/Message/FPARes");
				/*PabExPayFastpayFPARes fastpayFPARes = new PabExPayFastpayFPARes();
				fastpayFPARes.setInstId(instId);
				fastpayFPARes.setDate(date);
				fastpayFPARes.setSignNo(signNo);
				fastpayFPARes.setExtension(extension);
				fastpayFPARes.setAcntType(acntType);
				fastpayFPARes.setTokenNo(tokenNo);
				fastpayFPARes.setBankSerialNo(bankSerialNo);*/
				
				SignatureMessage signature = getSignatureMessage(retString);
				
				signMessageFPARes.setFPARes(fastpayFPARes);
				signMessageFPARes.setSignature(signature);
				fastpay.setMessage(signMessageFPARes);
				
			} catch (GopayException e) {
				e.printStackTrace();
			}
		}
		fastpay.setOutStlmCd(BankConstants.BANK_LOGO_PAB);
		//log.info("parse   message :"+fastpay);
		return fastpay;
	}

	public Object parseCpRes(Object messageData) {
		SignFastpayCPRes fastpay = new SignFastpayCPRes();
		String retString = null;
		if (messageData instanceof byte[]) {
			retString = new String((byte[]) messageData);
		} else if (messageData instanceof String) {
			retString = (String) messageData;
		}
		if(retString.indexOf("errorCode")==-1){
			// 解析文件，生成document对象
			try {
				/*InputStream inputStream = new ByteArrayInputStream(retString.getBytes());
				Document document = builder.parse(inputStream);

				// 获取节点值
				//机构标识
				String instId = getStringFromDom("CPRes", "instId", document);
				//流水号
				String serialNo = getStringFromDom("CPRes", "serialNo", document);
				//银行卡代号
				String signNo = getStringFromDom("CPRes", "signNo", document);
				//交易金额是否透支
				String overdraft = getStringFromDom("CPRes", "overdraft", document);
				//消息扩展
				String extension = getStringFromDom("CPRes", "Extension", document);
				//银行流水号
				String bankSerialNo = getStringFromDom("CPRes", "bankSerialNo", document);
				//交易金额
				String amount = getStringFromDom("CPRes", "amount", document);
				//银行卡Token号
				String tokenNo = getStringFromDom("CPRes", "TokenNo", document);
				//交易货币代码
				String currency = getStringFromDom("CPRes", "currency", document);
				//银行清算日期
				String liquDate = getStringFromDom("CPRes", "liquDate", document);*/
				
				
				SignMessageCPRes signMessageCPRes = new SignMessageCPRes();
				PabExPayFastpayCPRes fastpayCPRes = (PabExPayFastpayCPRes)DomParseXmlUtil.fromXml
						(retString, PabExPayFastpayCPRes.class, "Fastpay/Message/CPRes");
				/*PabExPayFastpayCPRes fastpayCPRes = new PabExPayFastpayCPRes();
				fastpayCPRes.setInstId(instId);
				fastpayCPRes.setSerialNo(serialNo);
				fastpayCPRes.setSignNo(signNo);
				fastpayCPRes.setOverdraft(overdraft);
				fastpayCPRes.setExtension(extension);
				fastpayCPRes.setBankSerialNo(bankSerialNo);
				fastpayCPRes.setAmount(amount);
				fastpayCPRes.setTokenNo(tokenNo);
				fastpayCPRes.setCurrency(currency);
				fastpayCPRes.setLiquDate(liquDate);*/
				
				SignatureMessage signature = getSignatureMessage(retString);
				
				signMessageCPRes.setCPRes(fastpayCPRes);
				signMessageCPRes.setSignature(signature);
				fastpay.setMessage(signMessageCPRes);
				
			} catch (GopayException e) {
				e.printStackTrace();
			}
		}
		fastpay.setOutStlmCd(BankConstants.BANK_LOGO_PAB);
		return fastpay;
	}

	public Object parseSoqRes(Object messageData, PabExPayMessage msg) {
		SignFastpaySOQRes fastpay = new SignFastpaySOQRes();
		String retString = null;
		if (messageData instanceof byte[]) {
			retString = new String((byte[]) messageData);
		} else if (messageData instanceof String) {
			retString = (String) messageData;
		}
		if(retString.indexOf("errorCode")==-1){
			// 解析文件，生成document对象
			try {
				SignMessageSOQRes signMessageSOQRes = new SignMessageSOQRes();
				SignatureMessage signature = getSignatureMessage(retString);
				if(signature != null){
					signMessageSOQRes.setSignature(signature);//签名部分
				}
				
				/*InputStream inputStream = new ByteArrayInputStream(retString.getBytes());
				Document document = builder.parse(inputStream);*/
				if(retString.indexOf("</SOQRes>") > 0){
					/*// 获取节点值
					//机构标识
					String instId = getStringFromDom("SOQRes", "instId", document);
					//流水号（订单号）
					String serialNo = getStringFromDom("SOQRes", "serialNo", document);
					//订单日期
					String orderDate = getStringFromDom("SOQRes", "orderDate", document);
					//交易类型 0提现; 1支付; 2退货
					String transType = getStringFromDom("SOQRes", "transType", document);
					//银行卡代号
					String signNo = getStringFromDom("SOQRes", "signNo", document);
					//交易金额
					String amount = getStringFromDom("SOQRes", "amount", document);
					//交易货币代码
					String currency = getStringFromDom("SOQRes", "currency", document);
					//处理状态  Y 成功；N 失败；U 未知状态（交易单正在处理中）
					String status = getStringFromDom("SOQRes", "status", document);
					//失败原因
					String cause = getStringFromDom("SOQRes", "cause", document);
					//消息扩展
					String extension = getStringFromDom("SOQRes", "Extension", document);
					
					PabExPayFastpaySOQRes fastpaySOQRes = new PabExPayFastpaySOQRes();
					
					fastpaySOQRes.setInstId(instId);
					fastpaySOQRes.setSerialNo(serialNo);
					fastpaySOQRes.setOrderDate(orderDate);
					fastpaySOQRes.setTransType(transType);
					fastpaySOQRes.setSignNo(signNo);
					fastpaySOQRes.setAmount(amount);
					fastpaySOQRes.setCurrency(currency);
					fastpaySOQRes.setStatus(status);
					fastpaySOQRes.setCause(cause);
					fastpaySOQRes.setExtension(extension); */
					PabExPayFastpaySOQRes fastpaySOQRes = (PabExPayFastpaySOQRes)DomParseXmlUtil.fromXml
							(retString, PabExPayFastpaySOQRes.class, "Fastpay/Message/SOQRes");
					signMessageSOQRes.setSOQresFather(fastpaySOQRes);//报文主体部分
				} else if(retString.indexOf("</SOQResH>") > 0){
					/*// 获取节点值
					//机构标识
					String instId = getStringFromDom("SOQResH", "instId", document);
					//流水号（订单号）
					String serialNo = getStringFromDom("SOQResH", "serialNo", document);
					//订单日期
					String orderDate = getStringFromDom("SOQResH", "orderDate", document);
					//交易类型 0提现; 1支付; 2退货
					String transType = getStringFromDom("SOQResH", "transType", document);
					//银行卡代号
					String signNo = getStringFromDom("SOQResH", "signNo", document);
					//交易金额
					String amount = getStringFromDom("SOQResH", "amount", document);
					//交易货币代码
					String currency = getStringFromDom("SOQResH", "currency", document);
					//处理状态  Y 成功；N 失败；U 未知状态（交易单正在处理中）
					String status = getStringFromDom("SOQResH", "status", document);
					//失败原因
					String cause = getStringFromDom("SOQResH", "cause", document);
					//消息扩展
					String extension = getStringFromDom("SOQResH", "Extension", document);
					
					PabExPayFastpaySOQResH fastpaySOQResH = new PabExPayFastpaySOQResH();
					
					fastpaySOQResH.setInstId(instId);
					fastpaySOQResH.setSerialNo(serialNo);
					fastpaySOQResH.setOrderDate(orderDate);
					fastpaySOQResH.setTransType(transType);
					fastpaySOQResH.setSignNo(signNo);
					fastpaySOQResH.setAmount(amount);
					fastpaySOQResH.setCurrency(currency);
					fastpaySOQResH.setStatus(status);
					fastpaySOQResH.setCause(cause);
					fastpaySOQResH.setExtension(extension);*/
					PabExPayFastpaySOQResH fastpaySOQResH = (PabExPayFastpaySOQResH)DomParseXmlUtil.fromXml
							(retString, PabExPayFastpaySOQResH.class, "Fastpay/Message/SOQResH");
					signMessageSOQRes.setSOQresFather(fastpaySOQResH);//报文主体部分
				}
				fastpay.setMessage(signMessageSOQRes);//报文主体部分
				
			} catch (GopayException e) {
				e.printStackTrace();
			}
		}
		fastpay.setOutStlmCd(BankConstants.BANK_LOGO_PAB);
		return fastpay;
	}
	
	public SignFastpayFSPRes parseFSPRes(Object messageData) {
		SignFastpayFSPRes fastpay = new SignFastpayFSPRes();
		String retString = null;
		if (messageData instanceof byte[]) {
			retString = new String((byte[]) messageData);
		} else if (messageData instanceof String) {
			retString = (String) messageData;
		}
		if(retString.indexOf("errorCode")==-1){
			// 解析文件，生成document对象
			try {
				/*InputStream inputStream = new ByteArrayInputStream(retString.getBytes());
				Document document = builder.parse(inputStream);

				// 获取节点值
				//机构标识
				String instId = getStringFromDom("FSPRes", "instId", document);
				//交易码
				String tranCode = getStringFromDom("FSPRes", "tranCode", document);
				//流水号
				String serialNo = getStringFromDom("FSPRes", "serialNo", document);
				//交易货币代码
				String currency = getStringFromDom("FSPRes", "currency", document);
				//交易金额
				String amount = getStringFromDom("FSPRes", "amount", document);
				//银行清算日期
				String liquDate = getStringFromDom("FSPRes", "liquDate", document);*/
				
				
				SignMessageFSPRes signMessageFSPRes = new SignMessageFSPRes();
				PabExPayFastpayFSPRes fastpayFSPRes = (PabExPayFastpayFSPRes)DomParseXmlUtil.fromXml
						(retString, PabExPayFastpayFSPRes.class, "Fastpay/Message/FSPRes");
				/*PabExPayFastpayFSPRes fastpayFSPRes = new PabExPayFastpayFSPRes();
				fastpayFSPRes.setInstId(instId);
				fastpayFSPRes.setTranCode(tranCode);
				fastpayFSPRes.setSerialNo(serialNo);
				fastpayFSPRes.setCurrency(currency);
				fastpayFSPRes.setAmount(amount);
				fastpayFSPRes.setLiquDate(liquDate);*/
				
				SignatureMessage signature = getSignatureMessage(retString);
				
				signMessageFSPRes.setFSPRes(fastpayFSPRes);
				signMessageFSPRes.setSignature(signature);
				fastpay.setMessage(signMessageFSPRes);
				
			} catch (GopayException e) {
				e.printStackTrace();
			}
		}
		fastpay.setOutStlmCd(BankConstants.BANK_LOGO_PAB);
		return fastpay;
	}
	
	public PabFastpayErrorRes parseErrorRes(Object messageData) {
		PabFastpayErrorRes fastpay = new PabFastpayErrorRes();
		String retString = null;
		if (messageData instanceof byte[]) {
			retString = new String((byte[]) messageData);
		} else if (messageData instanceof String) {
			retString = (String) messageData;
		}
		if(retString.indexOf("errorCode")==-1){
			// 解析文件，生成document对象
			try {
				
				
				/*InputStream inputStream = new ByteArrayInputStream(retString.getBytes());
				Document document = builder.parse(inputStream);

				// 获取节点值
				//机构标识
				String instId = getStringFromDom("Error", "instId", document);
				//错误代码
				String errorCode = getStringFromDom("Error", "errorCode", document);
				//错误描述
				String errorMessage = getStringFromDom("Error", "errorMessage", document);
				//详细错误信息
				String errorDetail = getStringFromDom("Error", "errorDetail", document);
				//服务方代码
				String vendorCode = getStringFromDom("Error", "vendorCode", document);
				//消息扩展
				String extension = getStringFromDom("Error", "extension", document);*/
				
				
				MessageErrorRes messageErrorRes = new MessageErrorRes();
				PabExPayMessageErrorRes MessageErrorRes = (PabExPayMessageErrorRes)DomParseXmlUtil.fromXml
						(retString, PabExPayMessageErrorRes.class, "Fastpay/Message/Error");
				/*PabExPayMessageErrorRes MessageErrorRes = new PabExPayMessageErrorRes();
				MessageErrorRes.setInstId(instId);
				MessageErrorRes.setErrorCode(errorCode);
				MessageErrorRes.setErrorMessage(errorMessage);
				MessageErrorRes.setErrorDetail(errorDetail);
				MessageErrorRes.setVendorCode(vendorCode);
				MessageErrorRes.setExtension(extension);*/
				
				SignatureMessage signature = getSignatureMessage(retString);
				
				messageErrorRes.setError(MessageErrorRes);
				messageErrorRes.setSignature(signature);
				fastpay.setMessage(messageErrorRes);
				
			} catch (GopayException e) {
				e.printStackTrace();
			}
		}
		fastpay.setOutStlmCd(BankConstants.BANK_LOGO_PAB);
		return fastpay;
	}
	
	
	public Result parseResult(Object messageData, PabExPayMessage msg) throws GopayException {
		Result result = new Result();
		result.setSuccess(true);
		String retString = null;
		if (messageData instanceof byte[]) {
			retString = new String((byte[]) messageData);
		} else if (messageData instanceof String) {
			retString = (String) messageData;
		}

		if(retString.indexOf("</Error>") > 0){
			PabExPayMessageErrorRes errRes = (PabExPayMessageErrorRes)DomParseXmlUtil.fromXml
					(retString, PabExPayMessageErrorRes.class, "Fastpay/Message/Error");
			result.setSuccess(false);
			result.setBankRetCode(errRes.getErrorCode());
			result.setErrorMsg(errRes.getErrorMessage());
		}else if(retString.indexOf("</FPARes>") > 0){//鉴权
			PabExPayFastpayFPARes res = (PabExPayFastpayFPARes)DomParseXmlUtil.fromXml
					(retString, PabExPayFastpayFPARes.class, "Fastpay/Message/FPARes");
			result.setModel("RES", res);
		}else if(retString.indexOf("</SOQRes>") > 0){//查询当日订单
			PabExPayFastpaySOQResFather res = (PabExPayFastpaySOQResFather)DomParseXmlUtil.fromXml
					(retString, PabExPayFastpaySOQResFather.class, "Fastpay/Message/SOQRes");
			result.setModel("RES", res);
		}else if(retString.indexOf("</SOQResH>") > 0){//查询历史订单
			PabExPayFastpaySOQResFather res = (PabExPayFastpaySOQResFather)DomParseXmlUtil.fromXml
					(retString, PabExPayFastpaySOQResFather.class, "Fastpay/Message/SOQResH");
			result.setModel("RES", res);
		}else if(retString.indexOf("</CPRes>") > 0){//支付
			PabExPayFastpayCPRes res = (PabExPayFastpayCPRes)DomParseXmlUtil.fromXml
					(retString, PabExPayFastpayCPRes.class, "Fastpay/Message/CPRes");
			result.setModel("RES", res);
		}else if(retString.indexOf("</FSPRes>") > 0){//退款
			PabExPayFastpayFSPRes res = (PabExPayFastpayFSPRes)DomParseXmlUtil.fromXml
					(retString, PabExPayFastpayFSPRes.class, "Fastpay/Message/FSPRes");
			result.setModel("RES", res);
		}
		
		return result;
	}
	
	
	private String getStringFromDom(String bussType, String field, Document document) throws XPathExpressionException{
		return (String) xpath.evaluate(messageNode + "/" + bussType + "/" + field,document, XPathConstants.STRING);
	}
	
	/**
	 * 封装签名部分的对象
	 * @param retString
	 * @return
	 */
	private SignatureMessage getSignatureMessage(String retString){
		if(retString.indexOf("</Signature>") < 0){
			return null;
		}
		retString = retString.substring(retString.indexOf("<Signature"),retString.indexOf("</Signature>") + "</Signature>".length());
		XStream xstream = new XStream();
		xstream.autodetectAnnotations(true);
		xstream.processAnnotations(SignatureMessage.class);
		retString = retString.replaceAll("ds:", "");
		SignatureMessage signatureMessage= (SignatureMessage) xstream.fromXML(retString);
		return signatureMessage;
	}
	
	

	public static void main(String[] args) {
		/*String retString =  "<Fastpay><Message id=\"100000000000005\"><FPARes id=\"FPARes\"><instId>1204</instId></FPARes><ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">"+
				"<ds:SignedInfo>"+
				"<ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"></ds:CanonicalizationMethod>"+
				"<ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"></ds:SignatureMethod>"+
				"<ds:Reference URI=\"#FPARes\">"+
				"<ds:Transforms>"+
				"<ds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"></ds:Transform>"+
				"</ds:Transforms>"+
				"<ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></ds:DigestMethod>"+
				"<ds:DigestValue>S0NZ8dVmn0SEritpRU35meO9bKs=</ds:DigestValue>"+
				"</ds:Reference>"+
				"</ds:SignedInfo>"+
				"<ds:SignatureValue>"+
				"POIOHQOaZzmG/0MkiUTlkenrZCjuYUB5/a5syVQFyEPYRSRE/2A5LITL8/BSObXdLZqII6FrjJRo"+
				"k7eJ09NGl+97rHuZ30drvJIllze+MBpsri0LYflRtW9iATnD2wITCuoyGG21bLn9ZmTlUGA3bFqg"+
				"U3nGqt2u6+uqSaxVfWlGPtvvJpDTdQXhABBGNBWXpBaOJlsUesFOp9a28Jhl1B/l3fCkZdDJckPU"+
				"4L7iKz1sR4ttfec7UTK7wCqRlH7dBmgAQCMjR/EOzTw2u5m77SHvSe9r0DkwmrM+idhD9OE7Pfg6"+
				"hpw5uVTb/fqYv+5N7l7Fiik2fg3060geFFlT/A=="+
				"</ds:SignatureValue>"+
				"</ds:Signature></Message></Fastpay>";
		
		XStream xstream = new XStream();
		xstream.autodetectAnnotations(true);
		retString = retString.replaceAll("ds:", "");
		xstream.processAnnotations(SignFastpayFPARes.class);
		SignFastpayFPARes fastpay = (SignFastpayFPARes) xstream.fromXML(retString);
		System.out.println(fastpay.getMessage().getFPARes().getInstId());
		System.out.println(fastpay.getMessage().getSignature().getSignatureValue());*/
		
		
		String str = "<Fastpay><Message id=\"1482800770326\"><SOQRes id=\"SOQRes\"><serialNo>2016122703670732</serialNo><orderDate>20161227</orderDate><transType>1</transType><signNo>6230583000003338755</signNo><amount>0.01</amount><currency>156</currency><status>Y</status><cause>银行主机单笔代收成功！</cause><Extension/><instId>1248</instId></SOQRes><Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#SOQRes\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>pEvEvYeCl6fUd3Dzi7NCvr+Rtlk=</DigestValue></Reference></SignedInfo><SignatureValue>C5uaD10TtACsTDsve6rQ486lUe6Myy7Z6Wp/j1asY3qMnnSUOkJdVTTLYeB1OEnHkiFC+n1TkwBW"+
				"yUwIKbL9UwBONefgBnQQ79HuXt92eSNLW3CNm/aeaEr0PoA9u/gDFAfBabs7pOWHJ6bX59qZvxD3"+
				"EN8WL3fY9I/swv6cNgk=</SignatureValue></Signature></Message></Fastpay>";
		
		System.out.println(str.indexOf("</SOQRes>"));
		
		PabExPayFastpaySOQRes fastpaySOQRes = new PabExPayFastpaySOQRes();
		System.out.println(fastpaySOQRes.getId());
		
	}

	
	
}
